﻿Module SimulateClics

    Private Const MOUSEEVENTF_LEFTDOWN = &H2
    Private Const MOUSEEVENTF_LEFTUP = &H4

    Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer
    Private Declare Sub mouse_event Lib "user32" _
                        (ByVal dwFlags As Long, _
                         ByVal dx As Long, _
                         ByVal dy As Long, _
                         ByVal cButtons As Long, _
                        ByVal dwExtraInfo As Long)




    ''' <summary>
    ''' Simula clic en la posicion x,y
    ''' </summary>
    ''' <param name="x">posicion x</param>
    ''' <param name="y">posicion y</param>
    ''' <remarks></remarks>
    Public Sub Clic(ByVal x As Integer, ByVal y As Integer)
        SetCursorPos(x, y) ' Move the mouse to x,y
        Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&) 'Simulate Clic Down
        Call mouse_event(MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&)   'Simulate Clic Up
    End Sub


End Module
